<?php

namespace App\HttpController\Api;
use \EasySwoole\Core\Component\Di;
use APP\Lib\Redis\Redis;

/**
 * Class Index
 * @package App\HttpController
 */
class Index extends Base
{

    public function onRequest($action):?bool
    {
        //$this->writeJson(403,'你没有权限访问',[]);
        return true;
    }

    public function video(){

        $data = [
            'id'=>1,
            'name'=>'hello world 2',
            'params'=>$this->request()->getRequestParam()
        ];
        return $this->writeJson(201,'ok',$data);

    }

    /**
     *
     * @return bool
     */
    public function getVideo(){
      $db = Di::getInstance()->get('MYSQL');

     // return $this->writeJson(200,'ok',$db);
    }

    public function getRedis(){

        $redis = new \Redis();

        $redis->connect("127.0.0.1",6379,5);

        $redis->set("singwa456",90);

        return $this->writeJson(200,'ok',$redis->get('singwa456'));

}

    public function yaconf(){
        $result = \Yaconf::get('redis');
        return $this->writeJson(200,'ok',$result);
    }

}